<?php

session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}

$idemployee = $_GET["idemployee"];

$listreference = $_SESSION['listreference'];
$namereference = $_SESSION['namereference'];
$i = $_SESSION['slreference'];
$co = 0;
for ($j = 0; $j < $i; $j++) {
    if ($listreference[$j] == $idemployee)
        $co = 1;
}
if ($co == 0) {
    include 'operations/connection.php';
    $sql = "SELECT IDEmployee,FullName FROM employee WHERE IDEmployee='$idemployee'";
    $query = mysql_query($sql);
    $row = mysql_fetch_array($query);

    $namereference[$i] = $row[FullName];
    $listreference[$i] = $idemployee;
    $i = $i + 1;
}

$_SESSION['namereference'] = $namereference;
$_SESSION['listreference'] = $listreference;
$_SESSION['slreference'] = $i;

echo "<table border='1' class='table_th' style='height:22px;' cellspacing='0' width='100%'>
<tr style='background-color:#EEE;'>
<td colspan='2'>List Reference</td>

</tr>";
for ($j = 0; $j < $i; $j++) {
    echo "<tr >";
    echo "<td>" . $namereference[$j] . "</td>";
    echo "<td><a onclick='rmReference(" . $listreference[$j] . ")'><img src='images/del.png' /></a></td>";
    echo "</tr>";
}
echo "</table>";
?>